﻿<%@ Page MasterPageFile="~/Site1.Master" Language="C#" AutoEventWireup="true" CodeBehind="Cargo.aspx.cs" Inherits="DigDes.DSchool.SUPS.Web.UI.Cargo" EnableEventValidation="false" %>

    <asp:Content ID="Content1" ContentPlaceHolderID="web1" runat="server">   
        <br/><br/>
        <asp:GridView   ID="GridView1" 
                        runat="server"  AutoGenerateColumns="False" 
                        DataSourceID="ObjectDataSource1"  OnSelectedIndexChanged="GridView1_SelectedIndexChanged" 
                        DataKeyNames="ID" OnRowDataBound="GridView1_RowDataBound" 
                        AllowPaging="True" PageSize="10">

            <Columns>
                <asp:BoundField DataField="ID" Visible="false" />
                <asp:BoundField DataField="CargoName" HeaderText="Груз" SortExpression="CargoName" />
                <asp:BoundField DataField="CargoDescription" HeaderText="Описание груза" SortExpression="CargoDescription" />
                <asp:BoundField DataField="CargoCode" HeaderText="Код груза" SortExpression="CargoCode" />
                <asp:BoundField DataField="Mnemocode" HeaderText="Мнемокод" SortExpression="Mnemocode" />
                <asp:CheckBoxField DataField="IsUsed" HeaderText="Используется" SortExpression="IsUsed" />
                <asp:CheckBoxField DataField="IsEmpty" HeaderText="Порожний" SortExpression="IsEmpty" />
                <asp:ImageField dataimageurlfield="ID"  HeaderText="Картинка" dataimageurlformatstring="~\CargoImage.ashx?ID={0}"  ControlStyle-CssClass="image" />
            </Columns>
            <SelectedRowStyle BackColor="#c9e0ef" />
        </asp:GridView>

        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                              TypeName="DigDes.DSchool.SUPS.DataAccess.Database.CargoObjDataSource"
                              DataObjectTypeName="DigDes.DSchool.SUPS.DataAccess.Database.CargoRows" 
                              UpdateMethod="Update" EnablePaging="true"  
                              SelectCountMethod="SelectCount" SelectMethod="SelectPage" 
                              MaximumRowsParameterName="maximumRows">
        </asp:ObjectDataSource>

<br/>
        <asp:Button ID="AddButton" runat="server" Text="Добавить" OnClick="btAddClick" CssClass="button"/>&nbsp;&nbsp;
        <asp:Button ID="EditButton" runat="server" Text="Редактировать" OnClick="btEditClick" CssClass="button"/>&nbsp;&nbsp;
        <asp:Button ID="DeleteButton" runat="server" Text="Удалить" OnClick="btDeleteClick" CssClass="button"/>&nbsp;&nbsp;
    
<br/>
<br/>
        <asp:Label ID="infLabel"  Visible="false" runat="server" CssClass="infLabel"></asp:Label>
<br/>

        <asp:DetailsView ID="DetailsView1" visible="false" 
                         runat="server" AutoGenerateRows="false" OnItemUpdating="DetailsView1_ItemUpdating"
                         DataSourceID="ObjectDataSource2"  OnItemInserting="DetailsView1_ItemInserting" OnPreRender="DetailsView1_PreRender"
                         DataKeyNames="ID" Width="295px">  
            
            <Fields>
                <asp:BoundField DataField="ID" Visible="false" />
                <asp:BoundField DataField="CargoName" HeaderText="Груз" SortExpression="CargoName" />
                <asp:BoundField DataField="CargoDescription" HeaderText="Описание груза" SortExpression="CargoDescription" />
                <asp:BoundField DataField="CargoCode" HeaderText="Код груза" SortExpression="CargoCode" />
                <asp:BoundField DataField="Mnemocode" HeaderText="Мнемокод" SortExpression="Mnemocode" />
                <asp:CheckBoxField DataField="IsUsed" HeaderText="Используется" SortExpression="IsUsed" />
                <asp:CheckBoxField DataField="IsEmpty" HeaderText="Порожний" SortExpression="IsEmpty" />
                   <asp:TemplateField >
                      <EditItemTemplate>
                          <label class="dv_labels">Изображение:</label>
                          <asp:FileUpload ID="FileUpload" runat="server" />
                          <asp:Label ID="stat" runat="server"></asp:Label>
                      </EditItemTemplate>                      
                </asp:TemplateField>
                 <asp:BoundField DataField="Image" SortExpression="Image" Visible="false"/> 
            </Fields>
            
        </asp:DetailsView>


<br/>
        <asp:Button ID="Save_Button" runat="server" Text="Сохранить" Visible="false" OnClick="Save_Button_Click" CssClass="button" />&nbsp;&nbsp;
        <asp:Button ID="Cancel_Button" runat="server" Text="Отмена" Visible="false" OnClick="Cancel_Button_Click" CssClass="button" />
<br/>

        <asp:ObjectDataSource ID="ObjectDataSource2"
                              runat="server" SelectMethod="SelectRow"
                              TypeName="DigDes.DSchool.SUPS.DataAccess.Database.CargoObjDataSource" 
                              UpdateMethod="UpdatiPic" InsertMethod="InsertPic" DeleteMethod="Delete">
            
          


            <InsertParameters>
              
                <asp:Parameter Name="CargoName" Type="String" />
                <asp:Parameter Name="CargoDescription" Type="String" />
                <asp:Parameter Name="CargoCode" Type="String" />
                <asp:Parameter Name="Mnemocode" Type="String" />
                <asp:Parameter Name="IsUsed" Type="Boolean" />
                <asp:Parameter Name="IsEmpty" Type="Boolean" />
            
            </InsertParameters>

            <UpdateParameters>
              
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="CargoName" Type="String" />
                <asp:Parameter Name="CargoDescription" Type="String" />
                <asp:Parameter Name="CargoCode" Type="String" />
                <asp:Parameter Name="Mnemocode" Type="String" />
                <asp:Parameter Name="IsUsed" Type="Boolean" />
                <asp:Parameter Name="IsEmpty" Type="Boolean" />
              

            </UpdateParameters>

            <SelectParameters>
                <asp:ControlParameter ControlID="GridView1" Name="ID" PropertyName="SelectedValue" Type="Int32" />
             
            </SelectParameters>
             <DeleteParameters>
                 <asp:ControlParameter ControlID="GridView1" Name="ID" PropertyName="SelectedValue" Type="Int32" />
             </DeleteParameters>
        </asp:ObjectDataSource>

</asp:Content>